/*    */ package com.qmsk.session;
/*    */ 
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import java.util.regex.Matcher;
/*    */ import java.util.regex.Pattern;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class URLDoWhiteList
/*    */ {
/* 13 */   private static final Pattern pathMatcher = Pattern.compile("[\\w]/[\\w]", 
/* 14 */     2);
/*    */ 
/* 16 */   private String[] whiteListURLs = null;
/*    */ 
/* 18 */   private final String[] NULL_STRING_ARRAY = new String[0];
/*    */ 
/* 20 */   private final String URL_SPLIT_PATTERN = "[, ;\r\n]";
/* 21 */   private static final Logger logger = Logger.getLogger(URLDoWhiteList.class);
/*    */ 
/*    */   public void init(String whiteListURLStr)
/*    */   {
/* 27 */     this.whiteListURLs = strToArray(whiteListURLStr);
/*    */   }
/*    */ 
/*    */   public boolean isWhiteURL(String currentURL) {
/* 31 */     for (String whiteURL : this.whiteListURLs) {
/* 32 */       Matcher matcher = pathMatcher.matcher(currentURL);
/* 33 */       if (matcher.find())
/*    */       {
/* 35 */         logger.debug("url filter : white url list matches : [{}]  match [{}] continue + whiteURL + :" + 
/* 36 */           currentURL);
/* 37 */         return true;
/*    */       }
/* 39 */       logger.debug("url filter : white url list not matches : [{}] match [{}]" + 
/* 40 */         whiteURL + ":" + currentURL);
/*    */     }
/* 42 */     return false;
/*    */   }
/*    */ 
/*    */   private String[] strToArray(String urlStr)
/*    */   {
/* 51 */     if (urlStr == null) {
/* 52 */       return this.NULL_STRING_ARRAY;
/*    */     }
/* 54 */     String[] urlArray = urlStr.split("[, ;\r\n]");
/* 55 */     List urlList = new ArrayList();
/* 56 */     for (String url : urlArray) {
/* 57 */       url = url.trim();
/* 58 */       if (url.length() == 0) {
/*    */         continue;
/*    */       }
/* 61 */       logger.info(url);
/* 62 */       urlList.add(url);
/*    */     }
/* 64 */     return ((String[])urlList.toArray(this.NULL_STRING_ARRAY));
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.session.URLDoWhiteList
 * JD-Core Version:    0.5.3
 */